package com.swak.devtools.apidoc.parse.parser;

import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.util.Map;

import com.swak.devtools.apidoc.parse.ApiClass;

public class ReturnParser extends AbstractParser {

	/**
	 * 解析的基本参数
	 */
	private final Type type;
	private final Class<?> clazz;
	private final Map<TypeVariable<?>, Type> paramVariablesMappers;
	private ApiClass apiClass;

	public ReturnParser(Type type, Class<?> clazz, Map<TypeVariable<?>, Type> paramVariablesMappers) {
		this.type = type;
		this.clazz = clazz;
		this.paramVariablesMappers = paramVariablesMappers;
		this.apiClass = new ApiClass();
	}

	public ApiClass parse() {
		ParsedClass parsedClass = parseClass(type, clazz, this.paramVariablesMappers);
		this.apiClass = parsedClass.getApiClass();
		return this.apiClass;
	}

	public static ApiClass parse(Type type, Class<?> clazz, Map<TypeVariable<?>, Type> paramVariablesMappers) {
		return new ReturnParser(type, clazz, paramVariablesMappers).parse();
	}
}
